<style>
    .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
.ui-timepicker-div dl{ text-align: left; }
.ui-timepicker-div dl dt{ height: 25px; }
.ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
</style>
<script type="text/javascript" >
	stPublishToolbox.load_tooltip();
	stPublishToolbox.on_submitform('#stPublishToolbox', function(data){
        stPublishToolbox.loadPage('list_wall', '', '<?php _e("Successful", $config['plugin_name']) ?>');
    });
    stPublishToolbox.loadUploadButton('200');
    stPublishToolbox.loadRemoveButton();
        jQuery('#time_input').datetimepicker({"dateFormat":"dd-mm-yy"});
        media_display(jQuery("#type").val());
    function media_display(value){
        if(value == 'text' || value == 'image'){
            jQuery("#media").slideUp();
        }
        else
        {
            jQuery("#media").slideDown();
            jQuery("#image_choose").slideUp();
            jQuery("#upload_image").slideUp();
        }
        if(value == 'swf' || value == 'video')
        {
            jQuery("#preview_image").slideDown();
        }
        else
        {
            jQuery("#preview_image").slideUp();
        }
        if(value == 'image'){
            jQuery("#image_choose").slideDown();
            image_choose(1);
        }
        <?php if($permission == 1){?>
         if(value == 'video'){
            jQuery("#list_youtube").slideDown();
            insert_url(jQuery("#youtube").val());
        }
        else
            {
                jQuery("#list_youtube").slideUp();
            }
         <?php }?>
    }
    function publish(check){
        if(check == '1'){
            jQuery("#display_time").slideDown(null, function(){
                //jQuery("#display_time").slideDown();
            });
        }
        else{
             jQuery("#display_time").slideUp(null, function(){
               // jQuery("#display_time").slideUp();
            })
        }
    }
      function insert_url(value){
        jQuery("#media_value").val('http://youtube.com/v/'+value);
        jQuery("#image").val('http://img.youtube.com/vi/'+value+'/0.jpg');
    }
        function image_choose(value){
        if(value == 1){
            jQuery("#upload_image").slideDown();
            jQuery("#media").slideUp();
        }
        else
            {
                jQuery("#media").slideDown();
                jQuery("#media_value").val('');
                jQuery("#upload_image").slideUp();
            }
    }
    image_choose(<?php echo $result->image_type;?>);
    jQuery("#media_value").val('<?php echo $result->media;?>');
</script>
<div id="fb-root"></div>
<div class="w100p bgl">
    <div class="w100p bgr p5b">
      
        <form class="stform" id="stPublishToolbox" action="<?php echo admin_url('/admin.php?page=' . $config['plugin_name'] . '&action=' . $current_action) ?>" method="post" >
            <ul id="form" >
                <li>
                    <label><?php _e('Internal Content Title', $config['plugin_name']); ?>:</label>
                    <div class="required">
                        <input value="<?php echo $result->name;?>" class="required" name="data[name]" id="name" type="text"  />
                        <input value="<?php echo $result->id;?>" type="hidden" name="data[id]" id="id" />
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label><?php _e('Type', $config['plugin_name']); ?>:</label>
                    <div class="required">
                        <select name="data[type]" id="type" onchange="media_display(this.value);">
                            <option value="text" <?php if($result->type == 'text'){echo 'selected';}?> >Text</option>
                            <option value="image" <?php if($result->type == 'image'){echo 'selected';}?>>Image</option>
                            <option value="swf" <?php if($result->type == 'swf'){echo 'selected';}?>>Flash</option>
                            <option value="video" <?php if($result->type == 'video'){echo 'selected';}?>>Video</option>
                        </select>
                    </div>
                    <br clear="both" />
                </li>
                <?php if($permission == 1){?>
                <li id="list_youtube" style="display:none;">
                    <label><?php _e('Select YouTube video to publish', $config['plugin_name']); ?>:</label>
                    <div class="">
                        <select name="" id="youtube" onchange="insert_url(this.value);">
                           <?php foreach($youtube as $yo):?>
                            <option value="<?php echo $yo->video_id;?>" <?php if(str_replace('http://youtube.com/v/','',$result->media) == $yo->video_id){echo 'selected';} ?>><?php echo $yo->title;?></option>
                            <?php endforeach;?>
                        </select>
                    </div>
                    <br clear="both" />
                </li>
                <?php }?>
                <li id="text">
                    <label><?php _e('Content', $config['plugin_name']); ?>:</label>
                    <div>
                        <textarea title="content"
                                  class="" name="data[content]" cols="5" rows="5"
                                  id="content" tabindex="13" ><?php echo $result->content;?></textarea>
                    </div>
                    <br clear="both" />
                </li>
                <li  id="image_choose" style="display:none;">
                     <label><?php _e(' ', $config['plugin_name'])?></label>
                        <div>
                    <input type="radio" name="data[image_type]"  value="1" checked onclick="image_choose(this.value);" <?php if($result->image_type == 1){echo 'checked';}?>> Upload image<br />
                    <input type="radio" name="data[image_type]" value="0" onclick="image_choose(this.value);" <?php if($result->image_type == 0){echo 'checked';}?>> Image From URL
                        </div>
                     <br clear="both" />
                </li>
                <li  id="upload_image" style="display:none;">
                        <label><?php _e('Image', $config['plugin_name'])?>:</label>
                        <div>
                         <?php
                        $class_hide = "hide";
                        if (($result->image_upload) != '') {
                            $upload_data = wp_upload_dir();
                            $image = explode('/wp-content/',$result->image_upload);
                            $image = '../wp-content/'.$image[1];
                            $stplugin_picture_url = $upload_data['url'] . '/' . $result->image_upload;
                            $stplugin_picture_dir = $upload_data['path'] . '/' . $result->image_upload;
                            $class_hide = "";
                        }
                        ?>
                            <input value="<?php echo $result->image_upload; ?>" class="" name="data[image_upload]" id="id_image" type="hidden"/>
	                        <div class="upload_button_div">
	                            <span id="image" class="button image_upload_button">Upload Image</span>
	                            <span pictureID="image" id="reset_image" class="button image_reset_button <?php echo $class_hide ?>">Remove</span>
	                        </div>
                            <?php
                        if (($result->image_upload) != '') {
                        ?>
                            <img alt="" src="<?php echo $image;?>" id="image_image" class="hide preview" style="display: inline;"/>
                        <?php } ?>
                        </div>
                        <br clear="both" />
                </li>
                <li style="display:none;" id="media">
                    <label><?php _e('Media URL', $config['plugin_name']); ?>:</label>
                    <div>
                        <input value="<?php echo $result->media;?>" class="" name="data[media]" id="media_value" type="text"  />
                    </div>
                    <br clear="both" />
                </li>
                <li style="display:none;" id="preview_image">
                    <label><?php _e('Preview image', $config['plugin_name']); ?>:</label>
                    <div>
                        <input value="<?php echo $result->thumb;?>" class="" name="data[image]" id="image" type="text"  />
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label><?php _e('Publish', $config['plugin_name']); ?>:</label>
                    <div>
                        <input type="radio" name="data[publish]" value="0" checked onclick="publish(this.value);" <?php if($result->published == 0){echo 'checked';}?>> Publish now<br />
                         <input type="radio" name="data[publish]" value="1" onclick="publish(this.value);" <?php if($result->published == 1){echo 'checked';}?>> Publish later
                    </div>
                    <br clear="both" />
                </li>
                <li id="display_time" <?php if($result->published == 0){?>style="display:none;" <?php }?>>
                    <label><?php _e('Time', $config['plugin_name']); ?>:</label>
                    <div class="">
                        <input value="<?php echo $result->time;?>" class="" name="data[time]" id="time_input" type="text"  />
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <label><?php _e('To Facebook Page', $config['plugin_name']); ?>:</label>
                    <div>
                        <?php foreach ($page as $pa): ?>
                        <input type="checkbox" name="data[page][]" value="<?php echo $pa->pageid; ?>" <?php if(in_array($pa->pageid,json_decode($result->page))){echo 'checked';}?>>&nbsp;<?php echo $pa->pagename; ?><br/>
                        <?php endforeach; ?>
                    </div>
                    <br clear="both" />
                </li>
                <li>
                    <input type="submit" value="Publish"/>
                </li>


            </ul>

        </form>
    </div>
</div>